package Homework4;

public class Rectangle {
    private int top, bottom, left, right;

    public Rectangle(int top, int right, int bottom, int left) {
        if (right > left && top > bottom) {
            this.top = top;
            this.right = right;
            this.bottom = bottom;
            this.left = left;
        } else {
            this.top = this.bottom = this.left = this.right = 0;
        }
    }

    public void showLeftTop() {
        System.out.println(left + "," + top);
    }

    public void showRightTop() {
        System.out.println(right + "," + top);
    }

    public void showLeftBottom() {
        System.out.println(left + "," + bottom);
    }

    public void showRightBottom() {
        System.out.println(right + "," + bottom);
    }

    public int getHeight() {
        return top - bottom;
    }

    public int getWidth() {
        return right - left;
    }

    public int getArea() {
        return getHeight() * getWidth();
    }

    public int getPerimeter() {
        return 2 * (getHeight() + getWidth());
    }
}

